<!--候选人-->
<template>
	<el-card>
		<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
			<el-form-item class="form-button-right">
				<el-button v-auth="'attendance:shift:save'" type="primary" @click="addOrUpdateHandle()">添加候选人</el-button>
				<el-button v-auth="'attendance:shift:save'" type="primary" @click="addOrUpdateHandle()">导入</el-button>
				<el-button v-auth="'attendance:shift:save'" type="primary" @click="addOrUpdateHandle()">导出</el-button>
			</el-form-item>

			<el-form-item label="投递日期">
				<el-date-picker
					v-model="state.queryForm.timeDate"
					type="daterange"
					range-separator="~"
					start-placeholder="实际完成时间"
					end-placeholder="实际完成时间"
				/>
			</el-form-item>
			<el-form-item>
				<KeyQuery v-model="state.queryForm.keyword" @getDataList="getDataList()" />
			</el-form-item>
		</el-form>

		<Top style="margin-bottom: 20px"></Top>

		<div class="card" :key="index" v-for="(item, index) of defData">
			<el-card>
				<el-row>
					<el-col :span="2" class="right">
						<el-image fit="cover" :src="item.imgUrl" style="width: 80px; height: 80px; border: 1px solid #d3d3d340; border-radius: 50%">
							<template #error>
								<div class="image-slot">
									<!-- /*图片加载失败显示的内容*/ -->
									<img src="@/assets/R-C.jpg" />
								</div>
							</template>
						</el-image>
					</el-col>

					<el-col :span="14" class="left-and-centre">
						<div>
							<span style="font-size: 20px">{{ item.name }}</span>
							<span v-if="item.stateId === '0'" class="start-0">待初审</span>
							<span v-if="item.stateId === '1'" class="start-1">待二审</span>
							<span v-if="item.stateId === '2'" class="start-2">已通过</span>
						</div>

						<div>
							<span>{{ item.age }}</span
							>| <span>{{ item.xueli }}</span
							>| <span>{{ item.gongzuojingyan }}</span
							>|
							<span>{{ item.xinziyaoqiu }}</span>
						</div>

						<div style="color: #71707094">
							<span>{{ item.gongsi }}</span
							>| <span>{{ item.zhiwei }}</span
							>|
							<span>{{ item.gongzuoshijian }}</span>
						</div>
					</el-col>

					<el-col :span="8" class="right">
						<el-button v-auth="'module:assetStorage:update'" type="primary" link @click="addOrUpdateHandle(item.id)">通过</el-button>
						<el-button v-auth="'module:assetStorage:update'" type="primary" link @click="addOrUpdateHandle(item.id)">淘汰</el-button>
					</el-col>
				</el-row>
			</el-card>
		</div>

		<el-pagination
			:current-page="state.page"
			:page-sizes="state.pageSizes"
			:page-size="state.limit"
			:total="state.total"
			layout="total, sizes, prev, pager, next, jumper"
			@size-change="sizeChangeHandle"
			@current-change="currentChangeHandle"
		>
		</el-pagination>

		<!-- 弹窗, 新增 / 修改 -->
	</el-card>
</template>

<style scoped>
.card {
	margin: 0 0 20px 0;
}
.card:hover {
	box-shadow: 0.3em 0.3em 1em rgba(0, 0, 0, 0.3);
}

.start-0 {
	color: #717070;
	background-color: #71707022;
	padding: 5px 10px;
	border-radius: 15px;
}

.start-1 {
	color: #098e50;
	background-color: #098e5022;
	padding: 5px 10px;
	border-radius: 15px;
}

.start-2 {
	color: #9c4d4d;
	background-color: #9c4d4d22;
	padding: 5px 10px;
	border-radius: 15px;
}

.left-and-centre > * {
	margin: 10px 0;
	> span {
		margin: 0 5px;
	}
}

.right {
	align-self: center;
	text-align: right;
	padding: 0px 10px;
}
</style>

<script setup lang="ts" name="AttendanceShiftIndex">
import { useCrud } from '@/hooks'
import { reactive, ref } from 'vue'
import { IHooksOptions } from '@/hooks/interface'

import Top from './line/top.vue'

const state: IHooksOptions = reactive({
	dataListUrl: '/nb/shift/page',
	deleteUrl: '/nb/shift/delete',
	queryForm: {}
})
const queryList = ref()
const addOrUpdateRef = ref()
const addOrUpdateHandle = (id?: number) => {
	addOrUpdateRef.value.init(id)
}

const defData = ref()
const fnf = () => {
	defData.value = [
		{
			name: '张翰',
			stateId: '2',
			age: '28岁',
			xueli: '本科',
			gongzuojingyan: '5年经验',
			xinziyaoqiu: '10k以上',
			gongsi: '腾讯',
			zhiwei: '高级工程师',
			gongzuoshijian: '2015年—至今'
		},
		{
			name: '林允',
			stateId: '1',
			age: '28岁',
			xueli: '大专',
			gongzuojingyan: '大专',
			xinziyaoqiu: '大专',
			gongsi: '大专',
			zhiwei: '大专',
			gongzuoshijian: '大专'
		}
	]
}

fnf()

const findOrgStaffRef = ref()
const open = () => {
	console.info('1111')
	findOrgStaffRef.value.init()
}
const fn = () => {
	console.info('员工选择 -返现')
}

const { getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle } = useCrud(state)
</script>
